#include "client.h"

static int get_ser_fd(void);                                   
int main(int argc, char *argv[]){

    while(1){
        int num = login_register();
        if(num >= 0){
            close(num);
            break;
        }
        
    }
    while(1){

        int rn = token_login();
        if(rn == -1){
            printf("failed\n");
            break;
        }
        printf("succussful\n");
        break;
        
    }
    return 0;
}
static int get_ser_fd(void){                                   
    int ser_fd = socket(AF_INET,SOCK_STREAM,0);                
    ERROR_CHECK(ser_fd,-1,"socket");                           
                                                               
    struct sockaddr_in ser_addr;                               
    ser_addr.sin_family = AF_INET;                             
    int ret = inet_pton(AF_INET,"127.0.0.1",&ser_addr.sin_addr);
    ERROR_CHECK(ret,-1,"inet_pton");                           
    ser_addr.sin_port = htons(atoi("8080"));                   
                                                               
    ret = connect(ser_fd,(struct sockaddr*)&ser_addr,sizeof(ser_addr));
    ERROR_CHECK(ret,-1,"connect");                             
                                                               
    return ser_fd;                                             
}                                                              
                                                               
